<%-- 
    Document   : process_vote
    Created on : Oct 30, 2009, 5:12:26 PM
    Author     : Phong
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" import="DAOClass.*,java.sql.*,java.text.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/form.css" />
        <link rel="stylesheet" href="css/style.css" />
        <link rel="stylesheet" href="css/font.css" />
        <style>
            .tableVote {
                border-width: 1px 1px 1px 1px;
                border-spacing: 1px;
                border-style: solid solid solid solid;
                border-color: blue blue blue blue;
                border-collapse: collapse;
                background-color: white;
            }
  
        </style>

        <title>JSP Page</title>
    </head>
    <body>



        <%
            vote v = new vote();
            NumberFormat nbFormat = new DecimalFormat("0.0");
            int idVote = Integer.parseInt(request.getParameter("voteID"));
            int idVoteSelect = Integer.parseInt(request.getParameter("VoteSelect"));
            String voteName = request.getParameter("VoteName");
            v.vote(idVoteSelect);
            ResultSet getVoteDetail = v.voteSelect(idVote);
            double TOTAL = v.sumSelected(idVote);
            double _selectted = 0;
            String[] color = {"#D00012", "blue", "#FDCE02", "#F09F81", "#E3F2E1", "black", "#B98527", "#A9602E", "#9AD39", "#D45A13"};
            String temp;
            int i = 0;

        %>
        <table border="1" width="62%" class="tableVote">
            <thead>
                <tr>
                    <th colspan="4" align="left">
                        <%=voteName%>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
            while (getVoteDetail.next()) {
                _selectted = (getVoteDetail.getDouble("Selectted") * 100) / TOTAL;
                temp = nbFormat.format(_selectted);
                %>

                <tr>
                    <td width="16%"><%=getVoteDetail.getString("VoteSelect")%></td>
                    <%

                    %>

                    <td width="68%">
                        <table bgcolor="<%=color[i]%>" width="<%=_selectted%>%" height="10px">
                            <tr height="10px"><td height="10px"></td></tr>
                        </table>

                    </td>
                    <td width="7%"><%=temp%> &nbsp;%</td>


                    <td width="9%" class="fontVote"><%=getVoteDetail.getString("Selectted")%> Phiếu</td>
                </tr>	


                <%
                i++;
            }
                %>
                <tr>
                    <td colspan="4" class="fontVote">Tổng cộng có tất cả <%=TOTAL%> phiếu</td>
                </tr>

            </tbody>
        </table>

    </body>
</html>
